﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using SqlSugar;

namespace WorkshopModule.Models {
    /// <summary>
    /// 机台数据模型
    /// </summary>
    public class MachineModel : INotifyPropertyChanged {

        /// <summary>
        /// 机台编号
        /// </summary>
        //public int Id { get; set; }

        private int id;
        //[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
        public int Id {
            get { return id; }
            set {
                id = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Id"));
                }
            }
        }

        /// <summary>
        /// 机台名称
        /// </summary>
        //public string MachineName { get; set; }
        private string _MachineName;
        //[SugarColumn(ColumnName = "MachineName")]
        public string MachineName {
            get { return _MachineName; }
            set {
                _MachineName = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("MachineName"));
                }
            }
        }


        /// <summary>
        /// 状态
        /// </summary>
        //public string Status { get; set; }
        private string _Status;
        //[SugarColumn(ColumnName = "Status")]
        public string Status {
            get { return _Status; }
            set {
                _Status = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Status"));
                }
            }
        }


        /// <summary>
        /// 计划任务数量
        /// </summary>
        //public int PlanCount { get; set; }
        private int _PlanCount;
        //[SugarColumn(ColumnName = "PlanCount")]
        public int PlanCount {
            get { return _PlanCount; }
            set {
                _PlanCount = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("PlanCount"));
                }
            }
        }


        /// <summary>
        /// 已完成任务数量
        /// </summary>
        //public int FinishedCount { get; set; }
        private int _FinishedCount;
        //[SugarColumn(ColumnName = "FinishedCount")]
        public int FinishedCount {
            get { return _FinishedCount; }
            set {
                _FinishedCount = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("FinishedCount"));
                }
            }
        }


        /// <summary>
        /// 工单编号
        /// </summary>
        //public string OrderNo { get; set; }
        private string _OrderNo;
        //[SugarColumn(ColumnName = "OrderNo")]
        public string OrderNo {
            get { return _OrderNo; }
            set {
                _OrderNo = value;
                if (PropertyChanged != null) {
                    PropertyChanged(this, new PropertyChangedEventArgs("OrderNo"));
                }
            }
        }


        /// <summary>
        /// 完成百分比(只读)
        /// </summary>
        //[SugarColumn(ColumnName = "Percent")]
        public double Percent {
            get {
                return FinishedCount * 100.0 / PlanCount;
            }
        }

        public event PropertyChangedEventHandler? PropertyChanged;
    }
}
